home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows (5th Edition) / Programming Windows, 5th ed. - Companion CD (097-0002183)(1999).iso / Chap17 / FontFill / FontFill.c next >
Encoding:
C/C++ Source or Header  |  1998-10-09  |  1.2 KB  |  40 lines

  1. /*-----------------------------------------
  2.    FONTFILL.C -- Using Path to Fill Font
  3.                  (c) Charles Petzold, 1998
  4.   -----------------------------------------*/
  5.  
  6. #include <windows.h>
  7. #include "..\\eztest\\ezfont.h"
  8.  
  9. TCHAR szAppName [] = TEXT ("FontFill") ;
  10. TCHAR szTitle [] = TEXT ("FontFill: Using Path to Fill Font") ;
  11.  
  12. void PaintRoutine (HWND hwnd, HDC hdc, int cxArea, int cyArea)
  13. {
  14.      static TCHAR szString [] = TEXT ("Filling") ;
  15.      HFONT        hFont ;
  16.      SIZE         size ;
  17.  
  18.      hFont = EzCreateFont (hdc, TEXT ("Times New Roman"), 1440, 0, 0, TRUE) ;
  19.  
  20.      SelectObject (hdc, hFont) ;
  21.      SetBkMode (hdc, TRANSPARENT) ;
  22.  
  23.      GetTextExtentPoint32 (hdc, szString, lstrlen (szString), &size) ;
  24.  
  25.      BeginPath (hdc) ;
  26.      TextOut (hdc, (cxArea - size.cx) / 2, (cyArea - size.cy) / 2,
  27.                     szString, lstrlen (szString)) ;
  28.      EndPath (hdc) ;
  29.  
  30.      SelectObject (hdc, CreateHatchBrush (HS_DIAGCROSS, RGB (255, 0, 0))) ;
  31.      SetBkColor (hdc, RGB (0, 0, 255)) ;
  32.      SetBkMode (hdc, OPAQUE) ;
  33.  
  34.      StrokeAndFillPath (hdc) ;
  35.  
  36.      DeleteObject (SelectObject (hdc, GetStockObject (WHITE_BRUSH))) ;
  37.      SelectObject (hdc, GetStockObject (SYSTEM_FONT)) ;
  38.      DeleteObject (hFont) ;
  39. }
  40.